/**
 * @file bsp_multibuffer.h
 * @author liufeng (liufeng@injoinic.com)
 * @brief multibuffer
 * @version 0.1
 * @date 2024-12-01
 *
 * @copyright Copyright (c) 2024  injoinic
 *
 */

#ifndef __BSP_MULTIBUFFER_H__
#define __BSP_MULTIBUFFER_H__

#include "stdint.h"

#define NUM_OF_BUFF      (4)  // 缓冲区的数目
#define SINGLE_BUFF_SIZE (14) // 单个缓冲区的元素个数

typedef struct DataBuffTypedef DataBuffTypedef;
struct DataBuffTypedef
{
    uint8_t data_buff[NUM_OF_BUFF][SINGLE_BUFF_SIZE]; // 多缓冲区
    uint8_t head, tail;                               // 队列头，队列尾

    uint8_t* (*pf_write_addr)(DataBuffTypedef*);      // 获取写缓冲区地址
    void (*pf_move_tail)(DataBuffTypedef*);           // 移动尾指针

    uint8_t* (*pf_read_addr)(DataBuffTypedef*);       // 获取读缓冲区地址
    void (*pf_move_head)(DataBuffTypedef*);           // 移动头指针
};

void data_buff_construct(DataBuffTypedef* buffer);

#endif /* __BSP_MULTIBUFFER_H__ */
